package ma.jee.portailReservation.service.announce.Impl;

import ma.jee.portailReservation.persistence.announce.ITravelAgencyDAO;
import ma.jee.portailReservation.persistence.announce.TravelAgency;
import ma.jee.portailReservation.service.announce.DisplayTravelAgency;
import ma.jee.portailReservation.service.announce.IDisplayTravelAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 02/01/12
 * Time: 23:38
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayTravelAgencyService")
public class DefaultDisplayTravelAgencyService implements IDisplayTravelAgencyService {

    @Autowired
	@Qualifier("hibernateTravelAgencyDAO")
	private ITravelAgencyDAO travelAgencyDAO;

    @Override
    @Transactional(readOnly=true)
    public List<DisplayTravelAgency> getAllDisplayTravelAgencies() {

         List<DisplayTravelAgency> result = new ArrayList< DisplayTravelAgency >();

        for(TravelAgency travelAgency : travelAgencyDAO.findAll()) {
                  result.add(new DisplayTravelAgency(travelAgency));
        }

        return result;
    }
}
